<%@ page import="instructor.sample.*" %>
<% 
String username =  request.getParameter("username");
String password = request.getParameter("password");
String firstname = null;
String lastname = null;
String customername = null;
int userid = 0;
String rolename = null;
int roleid = 0;
int customerid =0;

ValidUser u = new ValidUser();
u.setUserName(username);
u.setPassword(password);
rolename=u.getRoleName();
roleid=u.getRoleId();
userid=u.getUserId();
u.closeConnection();

if (rolename.equals("None"))  {
  response.sendRedirect("logonerror.jsp"); 
 	return ;
}

session.setAttribute("roleid",roleid + "");
session.setAttribute("rolename",rolename);
session.setAttribute("userid",userid +"");
session.setAttribute("username",username +"");

if (rolename.equals("Customer")) {

Customer c = new Customer();
c.setCustomerInfo(userid);
customerid = c.getCustomerid();
firstname = c.getFirstname();
lastname = c.getLastname();
customername = c.getCustomerName();
session.setAttribute("customerid",customerid + "");
session.setAttribute("firstname",firstname);
session.setAttribute("lastname",lastname);
session.setAttribute("customername",customername);
c.closeConnection();

response.sendRedirect("customerhome.jsp");
}


%>




